home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Installer SDK Cornucopia 1.0.2 / Script Examples / Rule Function [inrf] Example / DoRuleFunction.c < prev    next >
Encoding:
Text File  |  1996-09-27  |  1.5 KB  |  56 lines  |  [TEXT/MPS ]

  1. //
  2. //    ruleFunction.c
  3. //
  4. //        This code resource will be called as a Rule Function ( 'inrf' ) from
  5. //        within the "Rule Function [inrf] Example" example.
  6. //
  7. //        The function below simply calls Gestalt for the system version.
  8. //        If the system version is equal to or greater than 7.5, the function
  9. //        returns true.  Otherwise, it returns false.  If the call to
  10. //        Gestalt returns an error, an alert is displayed, and we exit
  11. //        to shell, cancelling installation.
  12. //
  13. //        Copyright 1993-1996, Apple Computer, Inc., All Rights Reserved
  14. //
  15.  
  16.  
  17. #ifndef __Errors__
  18. #include <Errors.h>
  19. #endif
  20.  
  21. #include <SegLoad.h>
  22. #include <Gestalt.h>
  23. #include <Dialogs.h>
  24. #include <Types.h>
  25.  
  26. #include "InstallerScript.h"
  27.  
  28. #define ErrorAlertID    400
  29.  
  30. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  31. //    DoRuleFunction
  32. //
  33. //  NOTE: The name of this function 'DoRuleFunction' should
  34. //  match that specified in the -m option for the line in the
  35. //  makefile that compiles this code resource.
  36. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  37.  
  38. long DoRuleFunction(RuleFunctionPBPtr ourPBPtr)
  39. {
  40.     OSErr        myErr = noErr;
  41.     long        theVersion;    
  42.  
  43.     myErr = Gestalt(gestaltSystemVersion, &theVersion);
  44.     if (myErr == noErr)
  45.     {
  46.         if ( (theVersion & 0xFFFF) >= 0x0750 )        // if active system is 7.5.0 or greater
  47.              return (kTRUERuleFunctionResult);        //    return true
  48.         else
  49.             return (kFALSERuleFunctionResult);        // active system isn't 7.5.0 or greater, return false
  50.     }
  51.     else                                            // fatal error
  52.     {
  53.         Alert(ErrorAlertID,0L);
  54.         ExitToShell();
  55.     }
  56. }